/**
 * @Description: test
 * @Author: Hu Outstanding
 * @Date: 2022/2/21 20:14
 */
package com.aaa.three.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

public class AdminOperateAop {

        private static Logger log =  Logger.getLogger(AdminOperateAop.class);

        private long start = 0;

        public void haha(JoinPoint point){

            ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
            HttpServletRequest request = requestAttributes.getRequest();
            HttpServletResponse response = requestAttributes.getResponse();

            String addr = request.getRemoteAddr();
            String uri = request.getRequestURI();
            Object[] args = point.getArgs();



            start = System.currentTimeMillis();
            log.info("===================请求的地址是:================="+addr);
            log.info("===================请求的路径是:================="+uri);
            log.info("===================请求的参数是:================="+ Arrays.toString(args));
        }

        public void hehe(){
            long end = System.currentTimeMillis();
            log.info("=================耗时================="+ (end-start));
            log.info("=================结束了=================");
        }

}
